package com.mgr;

import java.util.Vector;

import com.qy.DaoMgr;
import com.qy.bean.DriveRecord;
import com.qy.bean.Option;
import com.qy.util.LogUtil;
import com.qy.util.TimeUtil;
/**
 * 服务行车记录
 * @author zwl
 * 2018年2月10日
 */
public class DriveRecordMgr {
    public static Vector<DriveRecord> driverRecord = new Vector<DriveRecord>(800);
    
    public static Vector<Integer> orderDriverIdList = new Vector<Integer>(800);
    
    public static void create(int orderDriverId,String point){
	DriveRecord dr = new DriveRecord();
	dr.setOp(Option.Insert);
	dr.setOrderDriverId(orderDriverId);
	dr.setSite(point);
	dr.setCreateTime(TimeUtil.getSysteCurTime());
	driverRecord.add(dr);
    }
    /**
     * 服务完成
     * @param odId
     */
    public static void completOd(int odId){
	orderDriverIdList.add(odId);
    }
    
    public static void save() {
	try {
	    Vector<DriveRecord> list = new  Vector<DriveRecord>(driverRecord);
	    driverRecord = new Vector<DriveRecord>(800);
	    for (DriveRecord dr : list) {
		DaoMgr.getDriveRecordDao().createDriveRecord(dr);
	    }
	} catch (Exception e) {
	    LogUtil.error("保存行车记录数据报错");
	}
	save2();
    }
    
    public static void save2() {
	try {
	    Vector<Integer> list = new  Vector<Integer>(orderDriverIdList);
	    orderDriverIdList = new Vector<Integer>(800);
	    for (Integer odId : list) {
		DriveLineMgr.createDL(odId);
	    }
	} catch (Exception e) {
	    LogUtil.error("生成行车记录数据报错");
	}
    }
}
